import { createBrowserRouter } from 'react-router-dom'
import App from '@/App'
import Layout from '@/pages/Layout'
import Login from '@/pages/Login'
import AuthRoute from '@/components/AuthRoute'
import Home from '@/pages/Home'
import Article from '@/pages/Article'
import Publish from '@/pages/Publish'

const router = createBrowserRouter([
    {
        path: '/',
        element: <App />,
        children: [
            {
                path:'',
                element: <AuthRoute><Layout /></AuthRoute>,
                children:[
                    {
                        // 设置为默认路由 
                        // 1. path:空字符
                        // 2. 定义为索引路由 index:true (缺陷，索引路由下不能有子路由)
                        path:'',
                        element:<Home/>
                    },
                    {
                        path: '/article',
                        element: <Article />
                    },
                    {
                        path: '/publish',
                        element: <Publish />
                    },
                ]
            }, 
            {
                path: '/login',
                element: <Login />
            },
        ]
    },
])

export default router